package br.com.massai.model.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "MODULE")
public class Module extends GenericEntity {

	private static final long serialVersionUID = 1392767139656401429L;

	@Id
	@SequenceGenerator(name = "seqModule", sequenceName = "seq_module", allocationSize = 1)
	@GeneratedValue(generator = "seqModule", strategy = GenerationType.SEQUENCE)
	private Long id;
	
	@Column(name = "ACRONYM", nullable = false, unique = true, length = 50, columnDefinition = "VARCHAR(50)")
	private String acronym;
	
	@Column(name = "NAME_MODULE", nullable = false, unique = true, length = 150, columnDefinition = "VARCHAR(150)")
	private String nameModule;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "parent_module_id", referencedColumnName = "id")
	private Module parentModule;
	
	@Transient
	private List<Function> functions;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getNameModule() {
		return nameModule;
	}

	public void setNameModule(String nameModule) {
		this.nameModule = nameModule;
	}

	public String getAcronym() {
		return acronym;
	}

	public void setAcronym(String acronym) {
		this.acronym = acronym;
	}

	public Module getParentModule() {
		return parentModule;
	}

	public void setParentModule(Module parentModule) {
		this.parentModule = parentModule;
	}

	public List<Function> getFunctions() {
		return functions;
	}

	public void setFunctions(List<Function> functions) {
		this.functions = functions;
	}
}